<!--#include file="lib/utf-8.asp"-->
<!--#include file="lib/connopen.asp"-->
<!--#include file="lib/asp-common-lib.asp"-->
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>EOC监控系统</title>
<!--#include file="lib/plugins.asp"-->
<style type="text/css">
  .ui-datepicker table {
    border: 0;
  }
</style>
<script type="text/javascript">
  $(function() {
    $(".datepicker").datepicker();
    function switch_type(){
      i=$("#iType").val();
      if(i==1){
        $(".type2").val("").prop("disabled",true);
        $(".type1").prop("disabled",false);
      }
      if(i==2){
        $(".type1").val("").prop("disabled",true);
        $(".type2").prop("disabled",false);
      }
    }
    $("#iType").change(function(){
      switch_type();
    });
    switch_type();
  });
</script>
<!--#include file="lib/js-google-analytics.asp"-->
</head>
<%
if not CheckPostFlag(session("aaPostFlag"),1,3) then call JumpErrorPage(2)

id=saferequest("id",1)
submit=saferequest("submit",0)
if id="" then
  action="add"
  dtDate=date()
else
  action="edit"
end if
if submit<>"" then
  '事务开始
  conn.BeginTrans
  on error resume next
  action=request("action")
  ndip=request("ndip")
  dtDate=FormatTime(request("dtDate"),"{Y}-{m}-{d} {h}:{n}:{s}")
  ' dtDate=replace(dtDate,"/","-")&" 00:00:00"
  iType=request("iType")
  iOperate=request("iOperate")
  sRefer=request("sRefer")
  sOldSoftVer=request("sOldSoftVer")
  sNewSoftVer=request("sNewSoftVer")
  sEmsVer=request("sEmsVer")
  bMiss=request("bMiss")
  if bMiss<>"1" then bMiss=0
  bHdmi=request("bHdmi")
  if bHdmi<>"1" then bHdmi=0
  sCpeMac=request("sCpeMac")
  sContent=request("sContent")
  sMemo=request("sMemo")
  dtLog=FormatTime(now(),"{Y}-{m}-{d} {h}:{n}:{s}")
  if action="edit" then
    '如果是编辑状态，提交或保存按钮把所有信息更新
    if submit="保存" then
      sql_act="update faultrecord set ndip='"&ndip&"',dtDate='"&dtDate&"',iType="&iType&",iOperate='"&iOperate&"',sRefer='"&sRefer&"',sOldSoftVer='"&sOldSoftVer&"',sNewSoftVer='"&sNewSoftVer&"',sEmsVer='"&sEmsVer&"',bMiss="&bMiss&",bHdmi="&bHdmi&",sCpeMac='"&sCpeMac&"',sContent='"&sContent&"',sMemo='"&sMemo&"',dtLog='"&dtLog&"' where id="&id
      ' response.write(sql_act)
      ' response.end
      
    end if
    if submit="删除" then
      sql_act="delete from faultrecord where id="&id
    end if
    call ExecuteCommand(sql_act,false)
  end if
  
  if action="add" then
    '如果是添加状态，新增和提交按钮起同样作用
    sql_act="insert into faultrecord(ndip,dtDate,iType,iOperate,sRefer,sOldSoftVer,sNewSoftVer,sEmsVer,bMiss,bHdmi,sCpeMac,sContent,sMemo,iUser) values('"&ndip&"','"&dtDate&"',"&iType&","&iOperate&",'"&sRefer&"','"&sOldSoftVer&"','"&sNewSoftVer&"','"&sEmsVer&"',"&bMiss&","&bHdmi&",'"&sCpeMac&"','"&sContent&"','"&sMemo&"',2)"
    ' response.write(sql_act)
    ' response.end
    id=ExecuteCommand(sql_act,true)
  
    ' call AddFee()
    
  end if
  
    
  
  
  
  
  
  
  
  '事务提交
  ' if conn.Errors.Count=0 then 
    ' conn.CommitTrans  '如果没有conn错误，则执行事务提交
  ' else
    ' conn.RollbackTrans '否则回滚
  ' end if

  if err.number=0 then 
    conn.CommitTrans  '如果没有conn错误，则执行事务提交
  else
    conn.RollbackTrans '否则回滚
    '回滚后的其他操作
    'strerr=err.Description
    url=request.ServerVariables("http_host")&request.ServerVariables("url")
    Response.Write "数据库错误！<br /><font color=red>Error # " & CStr(Err.Number) & "<br />" & Err.Description & "<br />Source: " & Err.Source &"<br />错误页面："&url&"</font><br />"
    Response.End
  end if
end if

if operate="删除" then response.redirect("faultrecord.asp")
if id<>"" then
  sql = "select * from faultrecord where id="&id
  Set rs = Server.CreateObject("ADODB.Recordset")
  rs.Open sql,conn,1,1
  if not rs.eof then
    ndip=rs("ndip")
    dtDate=rs("dtDate")
    iType=rs("iType")
    iOperate=rs("iOperate")
    sRefer=rs("sRefer")
    sOldSoftVer=rs("sOldSoftVer")
    sNewSoftVer=rs("sNewSoftVer")
    sEmsVer=rs("sEmsVer")
    bMiss=rs("bMiss")
    bHdmi=rs("bHdmi")
    sCpeMac=rs("sCpeMac")
    sContent=rs("sContent")
    sMemo=rs("sMemo")
  else
    'response.write("未找到数据")
    response.redirect("error.asp?id=1")
  end if
  rs.close
  set rs=nothing
end if
%>
<body>
<!--#include file="lib/header.asp"-->
<!--#include file="lib/nav.asp"-->
<div id="main">
<!--#include file="lib/col1.asp"-->
<!--#include file="lib/col2.asp"-->
  <div id="col3" role="main">
    <div id="col3_content" class="clearfix">
      <form id="form1" name="form1" method="post" class="yform columnar" role="application">
              <div class="type-text">
                <label for="ndip">NDIP</label>
                <input name="ndip" id="ndip" type="text" value="<%=ndip%>" />
              </div>
              <div class="type-text">
                <label for="dtDate">故障日期</label>
                <input class="datepicker" name="dtDate" id="dtDate" type="text" readonly="readonly" value="<%=dtDate%>" />
              </div>
              <div class="type-select">
                <label for="iType">类型*</label>
                <select name="iType" id="iType">
                  <option value="1" <%if iType=1 then response.write("selected='selected'")%>>ND</option>
                  <option value="2" <%if iType=2 then response.write("selected='selected'")%>>网管</option>
                </select>
              </div>
              <div class="type-text">
                <label for="sRefer">故障提交人</label>
                <input name="sRefer" id="sRefer" type="text" value="<%=sRefer%>" />
              </div>
              <div class="type-text">
                <label for="sContent">故障内容</label>
                <textarea name="sContent" id="sContent"><%=sContent%></textarea>
              </div>
              <div class="type-select">
                <label for="iOperate">操作*</label>
                <select name="iOperate" id="iOperate">
                  <option value="1" <%if iOperate=1 then response.write("selected='selected'")%>>Reboot</option>
                  <option value="2" <%if iOperate=2 then response.write("selected='selected'")%>>Update</option>
                  <option value="3" <%if iOperate=3 then response.write("selected='selected'")%>>Fix</option>
                  <option value="4" <%if iOperate=4 then response.write("selected='selected'")%>>Delete</option>
                  <option value="5" <%if iOperate=5 then response.write("selected='selected'")%>>Record</option>
                </select>
              </div>
              <div class="type-text">
                <label for="sOldSoftVer">ND原软件版本</label>
                <input name="sOldSoftVer" id="sOldSoftVer" class="type1" type="text" value="<%=sOldSoftVer%>" />
              </div>
              <div class="type-text">
                <label for="sNewSoftVer">ND新软件版本</label>
                <input name="sNewSoftVer" id="sNewSoftVer" class="type1" type="text" value="<%=sNewSoftVer%>" />
              </div>
              <div class="type-text">
                <label for="sEmsVer">网管版本</label>
                <input name="sEmsVer" id="sEmsVer" class="type2" type="text" value="<%=sEmsVer%>" />
              </div>
              <div class="type-text">
                <label for="sCpeMac">CPE MAC</label>
                <input name="sCpeMac" id="sCpeMac" type="text" value="<%=sCpeMac%>" />
              </div>
              <div class="type-check">
                <input name="bHdmi" id="bHdmi" type="checkbox" value="1" <%if bHdmi then response.write("checked='checked'")%> />
                <label for="bHdmi">HDMI</label>
              </div>
              <div class="type-check">
                <input name="bMiss" id="bMiss" type="checkbox" value="1" <%if bMiss then response.write("checked='checked'")%> />
                <label for="bMiss">误报</label>
              </div>
              <div class="type-text">
                <label for="sMemo">备注</label>
                <textarea name="sMemo" id="sMemo"><%=sMemo%></textarea>
              </div>
        <div class="type-button">
          <input id="id" type="hidden" value="<%=id%>" />
          <input id="action" name="action" type="hidden" value="<%=action%>" />
        <%if action="add" then%>
          <input type="submit" id="submit_add" name="submit" value="新增" />
        <%end if%>
        <%if action="edit" then%>
          <input type="submit" name="submit" value="保存" />
        <%end if%>
        <%if action="edit" then%>
          <input type="submit" id="submit_del" name="submit" value="删除" />
        <%end if%>
        </div>
      </form>
    </div>
  </div>
</div>
<!--#include file="lib/footer.asp"-->
</body>
</html>
<!--#include file="lib/connclose.asp"-->

